<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateSaleItemsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('sale_items', function (Blueprint $table) {
            $table->increments('id');
            $table->integer('order_id')->default(0)->unsigned()->comment('订单ID');
            $table->integer('product_id')->default(0)->unsigned()->comment('产品ID');
            $table->integer('num')->default(0)->unsigned()->comment('销售出库数量');
            $table->decimal('sale_price',8,2)->default(0)->unsigned()->comment('销售价格');
            $table->decimal('cost_price',8,2)->default(0)->unsigned()->comment('成本价格');
            $table->decimal('total_sale_price',8,2)->default(0)->unsigned()->comment('总销售价');
            $table->decimal('total_cost_price',8,2)->default(0)->unsigned()->comment('总成本价');
            $table->timestamps();
        });
        \DB::statement("ALTER TABLE `sale_items` comment '销售订单产品条目表'");

    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('sale_items');
    }
}
